home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Prograph Classic 2.6.1 / Prograph Reference Manual / Prograph Reference 5-7 / Prograph Reference 5-7.rsrc / TEXT_132.txt < prev    next >
Encoding:
Text File  |  1995-10-25  |  13.7 KB  |  281 lines

  1.  Chapter 5
  2.  
  3.  System Classes
  4.  
  5.  t An Overview  *167*
  6.  t Application Manager
  7.  t System Class Methods
  8.  t System Class Specifications
  9.  
  10. The terminology used in this chapter is as follows:
  11.  
  12. o ‚ÄúDeveloper‚Äù refers to the application developer.
  13.  
  14. o ‚ÄúUser‚Äù means the end user of the application.
  15.  
  16. o ‚ÄúUser methods‚Äù are methods designed by the developer.
  17.  
  18. o ‚ÄúUser window‚Äù is a window created by the developer, in contrast to a Prograph window. 
  19.  
  20. o An instance of a class ‚ÄúmyClass‚Äù or of one of its subclasses is denoted ¬´myClass¬ª. This notation is also used to mean a specific instance in some contexts: for example, in the description of the attributes of class Button, ¬´Button¬ª denotes the button whose attributes are being described. Specific instances that are not clear from context are further explained, for example ¬´Point of click¬ª. 
  21.  
  22. o Other data types are sometimes informally designated as <datatype>, as in <EventRecord of click>.
  23.  
  24. t    An Overview *167*
  25.  
  26. One of the most complex tasks in producing software for sophisticated graphics-based computers is the design and programming of the interface, which includes interaction by means of menus and windows rather than simple line-oriented input and output.
  27.  
  28. The interface development facilities of Prograph are an extension of the environment provided by the editor/interpreter and follow the same design principles. That is, the design of the application is integrated with its testing in a complete top-down fashion. 
  29. In Prograph, an application is an instance of the system class Application; that instance in turn refers to instances of other system classes, such as Menu and Window. The application recognized by the system is the value of the class attribute current of class Application. We will refer to this instance as the current application.
  30.  
  31. Choosing Run from the Exec menu activates the current application by setting its active? attribute to TRUE, causing the windows and menus on the so-called ‚Äúactive lists‚Äù of the current application to be displayed, and starting the Application Manager. Conversely, setting active? of an active application to FALSE hides its windows and menus and stops the Application Manager. Among other ways, this can be accomplished by choosing Stop Running or  Edit Application from the Exec menu if the Prograph editor menu bar is active.
  32.  
  33. The Application Manager intercepts all events, dispatching them to the application or to the editor/interpreter as appropriate. Events dispatched to the application can trigger the execution of user methods that implement the behavior of the application. As described in chapter 3, ‚ÄúThe Interpreter Environment,‚Äù execution and editing of these methods can proceed in parallel. During this process, both user windows and Prograph windows can be visible at the same time, the top window generally determining the context‚Äîthat is, whether the system is currently in the application state, displaying application menus, or in the editor/interpreter state, displaying Prograph menus. By selecting Switch Context from the Apple menu, the developer can force the context to be changed, regardless of the top window. Simultaneous editing and executing is particularly important in developing an application, since the effects of editing can be immediately observed on the application interface. 
  34.  
  35. Physical and visual effects on an application can be produced in a number of ways.
  36.  
  37. o    Some system attributes can be set. For example, setting the active? attribute of a ¬´Window¬ª to FALSE by using a Set operation removes this instance from the list of active windows of the current application. This, in turn, removes the window from the screen.
  38.  
  39. o    Certain primitives can be called. For instance, the primitive drag-rect tracks the cursor with an outline of a rectangle in a ¬´Canvas¬ª .
  40.  
  41. o    A Mac Method can be invoked to execute a toolbox procedure. The Mac Method PtInRect for example, given a point and a rectangle, returns TRUE if the point is within the rectangle.
  42.  
  43. t    Application Manager  *169*
  44.  
  45. Most system classes have instance attributes for specifying the names of user methods to be called in response to certain events dispatched to the application: such attributes are called event method attributes. For example, many Window Item subclasses have an attribute click method that names the method to call when a click is detected in a ¬´Window Item¬ª. If an event method attribute doesn‚Äôt specify a method (that is, its value is the empty string), no method is called when the corresponding event occurs.
  46.  
  47. If the value of an event method attribute is a nonempty string that does not name an existing method, then, when the corresponding event is detected, a dialog is displayed asking the developer whether or not the method should be created. This is analogous to the situation that arises when an attempt is made to execute an operation with no corresponding method (see chapter 3, ‚ÄúThe Interpreter Environment‚Äù).
  48.  
  49. Instances of certain system classes can appear on-screen, namely ¬´Window¬ªs, ¬´Menu¬ªs, ¬´Window Item¬ªs and ¬´Menu Item¬ªs. The instances that are displayed when an application is running are kept in various lists, detailed below, and are displayed in the order of their occurrence in these lists: ¬´Window¬ªs and ¬´Window Item¬ªs from front to back, ¬´Menu¬ªs from left to right in the menu bar, and ¬´Menu Item¬ªs from top to bottom.
  50.  
  51. The values of the attributes windows and menus of an ¬´Application¬ª are lists of ¬´Window¬ªs and ¬´Menu¬ªs respectively, called the active windows and menus of ¬´Application¬ª. When an application is activated, the attribute active? of each of its active windows and menus is set to TRUE, causing them to be displayed.
  52.  
  53. The item list attribute of a ¬´Window¬ª (or ¬´Menu¬ª) contains a list of ¬´Window Item¬ªs (or ¬´Menu Item¬ªs), which are displayed when the ¬´Window¬ª (or ¬´Menu¬ª) is displayed.
  54.  
  55. When the application is running, pressing the Shift, Option, and Command keys while single-clicking on a ¬´Window Item¬ª that has a click method (that is, all ¬´Window Item¬ªs except for instances of Text or its subclasses) opens an editing window on the first case of the method named in the click method attribute of the ¬´Window Item¬ª. If the name does not correspond to an existing method, a dialog is displayed asking the developer whether or not to create the method.
  56.  
  57. Similarly, pressing the Shift, Option, and Command keys while selecting a ¬´Menu Item¬ª opens the method named in the event method attribute method, or displays a dialog as explained in the preceding paragraph. 
  58.  
  59. t    System Class Methods  *170*
  60.  
  61. A number of methods are shipped with the System Classes in Prograph Classic. Some of these supply basic functionality, such as Quit, Cut, Copy, Paste and Clear in class Menu. Others have to do with handling events. All these methods may be examined and modified (or overridden) by the user.
  62.  
  63. NOTE: The following convention has been adopted for names of System Classes and of System Class methods supplied by Prograph International:  each word in the name begins with a capital letter. An example is the Mouse Down method in class Application. Keeping this convention in mind should reduce the likelihood of name conflicts (for example, you may want to have your method names all be lower-case).
  64.  
  65. Application  *171*
  66.  
  67. Notify
  68.  
  69. Prograph passes all events to this method. Notify has one case for each type of event: null event, mouse down, key, update, activate, Apple Event, and suspend/resume. 
  70.  
  71. null event                 Calls /Idle of the front window.    
  72.  
  73. mouse down              Calls Window/Mouse Down if the mouse was clicked in a 
  74.                                   window, or Application/Mouse Down if the mouse was 
  75.                                   clicked in the menu bar or the desktop.     
  76.  
  77. key                          Calls Application/Menu Click for command keys, and calls 
  78.                               /Key of the front window otherwise.    
  79.  
  80. update                   Figures out which window is to be updated and calls its /Update 
  81.                                 method.    
  82.  
  83. activate                 Figures out which window is to be activated (or deactivated) and 
  84.                                calls its /Activate method.    
  85.  
  86. Apple Event           Calls one of the Application‚Äôs aevent methods.    
  87.  
  88. suspend/resume    Activates or deactivates the front window by calling its /Activate 
  89.                                 method.    
  90.  
  91. Mouse Down  *171*
  92.  
  93. Handles mouse down events in the menu bar and the desktop. Called from Application/Notify. 
  94.  
  95. Menu Click *171*
  96.  
  97. Called when a pull-down menu item is selected or a menu key equivalent is pressed. The menu item‚Äôs click method is called, or if the About‚Ķ menu item in the Apple menu is selected, the Application‚Äôs About method is called. If a desk accessory is selected in the Apple menu, the desk accessary is opened. Called from Application/Notify and Application/Mouse Down.
  98.  
  99. Front Window  *172*
  100.  
  101. Returns the front window, or NULL if there is no front window or if the front window does not belong to the Application. 
  102.  
  103. Update Menus  *172*
  104.  
  105. Called when the user clicks on the menu bar or types a Command key. Modify this method to keep your menus up to date. Called from Application/Notify and Application/Mouse Down. 
  106.  
  107. About  *172*
  108.  
  109. Empty About‚Ķ method. Modify this method to show your ‚ÄúAbout‚Äù dialog.
  110.  
  111. Menu
  112.  
  113.  
  114. Quit  *172*
  115.  
  116. Quits the current application. Calls /Close of all window items in all open windows.
  117.  
  118. Cut, Copy, Paste, & Clear  *172*
  119.  
  120. Perform editing operations on selected text items.
  121.  
  122. Window
  123.  
  124. Activate  *172*
  125.  
  126. Hilites the window‚Äôs items and calls the window‚Äôs activate method. Called by Application/Notify
  127.  
  128. Update  *172*
  129.  
  130. Redraws the window‚Äôs item list. Called by Application/Notify.
  131.  
  132. Idle  *173*
  133.  
  134. Calls sc-show-balloon to handle Balloon Help for the window; calls /Idle of the window‚Äôs selected item; then calls the window‚Äôs idle method. Called by Application/Notify.
  135.  
  136. Key  *173*
  137.  
  138. If the key is a tab, calls /Tab To Item of the window item to be tabbed to. If the key is enter or return, calls the click method of the window‚Äôs default button. Otherwise, calls /Key of the window‚Äôs selected item. The window‚Äôs key method is called only when the key event is not otherwise processed. Called by Application/Notify.
  139.  
  140. Mouse Down  *173*
  141.  
  142. Handles mouse down events in the window‚Äôs close box, grow box, zoom box, title bar and content. Calls the window‚Äôs /Close method when the close box is clicked. Called by Application/Notify.
  143.  
  144. Close  *173*
  145.  
  146. Closes a window and calls /Close of the window‚Äôs items.  This is the prescribed way of closing windows.
  147.  
  148. Open  *173*
  149.  
  150. Opens a window and calls /Open of the window‚Äôs items. This is the prescribed way of opening windows.
  151.  
  152. Bring To Front   *173*
  153.  
  154. Brings a window to the front.
  155.  
  156. Wind Draw Prep   *173*
  157.  
  158. Prepares a window for drawing.
  159.  
  160. Window Item
  161.  
  162. Mouse Down  *174*
  163.  
  164. Processes mouse down events in the window item, and then calls the item‚Äôs click method if it has one. Called by Window/Mouse Down.
  165.  
  166. Idle  *174*
  167.  
  168. Flashes the caret in the selected item and changes the cursor to the I-beam if it‚Äôs over an ¬´Edit Text¬ª item, or to the the arrow otherwise.
  169.  
  170. Update  *174*
  171.  
  172. Redraws the window item. Called by Window/Update.
  173.  
  174. Hilite  *174*
  175.  
  176. Hilites or unHilites the window item temporarily. Called by Window/Activate
  177.  
  178. Open  *174*
  179.  
  180. Does nothing. This method is provided for subclasses of Window Item which must be informed when their owning window is opened. Called from  Window/Open.
  181.  
  182. Close  *174*
  183.  
  184. Does nothing. This method is provided for subclasses of Window Item which must be informed when their owning window is closed. Called from  Window/Close and Application/Quit.
  185.  
  186. Bounds  *174*
  187.  
  188. Returns the bounding rectangle of the window item in window coordinates.
  189.  
  190. Canvas
  191.  
  192. Update  *175*
  193.  
  194. Draws the scroll bars and border of the canvas and calls the canvas‚Äô draw method. Overrides Window Item/Update. 
  195.  
  196. Scroll List
  197.  
  198. Mouse Down  *175*
  199.  
  200. Selects the Scroll List item when a mouse down occurs in it. Overrides Window Item/Mouse Down.
  201.  
  202. Tab To Item  *175*
  203.  
  204. Selects the Scroll List item. Called by Window/Key. 
  205.  
  206. Key  *175*
  207.  
  208. Arrow keys change the selection. Other keys are ignored. Called by Window/Key.
  209.  
  210. Edit Text    
  211.  
  212. Mouse Down  *175*
  213.  
  214. Selects the Edit Text item when a mouse down occurs in it. Overrides Window Item/Mouse Down.
  215.  
  216. Tab To Item  *175*
  217.  
  218. Selects the Edit Text item and selects all of the text in the item. Called by Window/Key.
  219.  
  220. Key  *175*
  221.  
  222. Arrow keys move the caret, the delete key deletes characters, and other keys are inserted into the item‚Äôs text. Called by Window/Key.
  223.  
  224. t    System Class Specifications  *176*
  225.  
  226. The interface of a Macintosh application consists of windows and menus. The Prograph Application Builder facilitates the building of such interfaces. It consists of a set of System classes defining the necessary interface elements, and a set of interactive, graphical editors for editing instances of system classes. The icons for System classes are distinguished from those for user-defined classes.
  227.  
  228. The System classes are described in this chapter, while the interactive graphical editors are described in chapter 4, ‚ÄúApplication Builder.‚Äù
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249. Key  *177*
  250.  
  251. Symbol    Description    
  252.  
  253.  
  254.                             a System class
  255.  
  256.  
  257. ¬†                         a System class attribute 
  258.  
  259.  
  260. ¬†                        an inherited System class attribute 
  261.  
  262.  
  263. ¬†                        a System instance attribute 
  264.  
  265.  
  266. ¬†                      an inherited System instance attribute 
  267.  
  268.  
  269. NOTE:
  270.  
  271. o    The System classes are described in alphabetical order. 
  272.  
  273. o    System attributes are supplied with default values, some of which cannot be changed. 
  274.  
  275. o    ‚ÄúNot settable‚Äù means that the attribute value cannot be set at runtime or in a Value window.
  276.  
  277. o    ‚ÄúNot settable on default‚Äù means that the default value of the attribute cannot be set.
  278.  
  279. o    An instance of a class is ‚Äúactive‚Äù if its instance attribute active? has the value TRUE. 
  280.  
  281.